<?

function smDrawButtons($a) {
	
	?><input type="hidden" class="attr" name="attr[<?=$a['id']?>]" value="<?=$a['attr']?>" /><?

	if ($a['tag'] & PT_LOCKED) {
	
	} else {
	
		if ($a['attr'] & AA_VISIBLE) { 
			?><a title='Disable «<?=$a['name']?>»' class="button visible" href="hide-<?=$a[id]?>/"><span>Disable</span></a><? 
		} else { 
			?><a title='Enable «<?=$a['name']?>»' class="button hidden" href="show-<?=$a[id]?>/"><span>Enable</span></a><?
		} 
	
	}
	
	?><a title='Edit «<?=$a['name']?>»' class="button edit" href="edit-<?=$a[id]?>/"><span>Edit</span></a><?

	if (!($a['tag'] & PT_MAIN)) { 

		?><div class="dragHandle"></div><?

	}
	
	if ($a['tag'] & PT_NODE) { 

		?><a title='Add node' class="button add" href="add-<?=$a['id']?>/"><span>Add</span></a><?

	}

	if (!($a['tag'] & (PT_MAIN | PT_SPECIAL | PT_LOCKED))) { 
	
		?><a title='Kill «<?=$a['name']?>»' class="button kill" href="delete-<?=$a[id]?>/"><span>Kill</span></a><?
	}
	
}

function smStructmap($page, $id = "") {
	
	?><ul<?=$id ? " id=\"$id\"" : ''?>><?
	
		foreach ($page as $p) {
			?><li id="obj-<?=$p['id']?>" class="object"><? 

				?><div class="buttonbar"> <? smDrawButtons($p) ?> </div><? 

				?><a href="edit-<?=$p['id']?>/" title="<?=$p['name']?>"><?=$p['name']?></a><?
			
				if ($p['data'])
					smStructmap($p['data'], "s$p[id]");
				
			?></li><?
		}
	
	?></ul><?
}



if (is_array($DATA['structmap'])) smStructmap($DATA['structmap'], 'struct');


?>